obda-mixer

Query Templates Syntax

A SPARQL template query is a SPARQL query with placeholders of the form

${id:source:quoting}

where id is an integer, source is a string of the form table_name.col_name, and quoting is one of {none, underscore, percent}. During the test phase, obda-mixer replaces the placeholders in the provided SPARQL templates with database values retrieved from the column table_name.col_name in the database. Blank spaces in such values are encoded according to the quoting policy. For instance, a value Little Color is kept as is if the none quoting is prescribed, is transformed into Little_Color if the underscore quoting is prescribed, and is transformed into Little%20Color if the percent quoting is prescribed. If p1, p2 are two placeholders with the same id part and retrieving values from different columns in the same table, then the values for p1, p2 will be retrieved from the same row. If p1, p2 are two placeholders having the same source part and id part, then they will be replaced by the same value.

We now provide an example. Consider the following query 08.rq from the NPD Benchmark:

PREFIX npdv: <http://sws.ifi.uio.no/vocab/npd-v2#>

SELECT *
WHERE {
  [ npdv:productionYear ?year ;
    npdv:productionMonth ?m ;
    npdv:producedGas     ?g ;
    npdv:producedOil     ?o 
 ]
 FILTER (?year > ${1:field_production_totalt_NCS_year.prfYear}) 
 FILTER(?m >= ${1:field_production_totalt_NCS_month.prfMonth} && ?m <= ${2:field_production_totalt_NCS_month.prfMonth} )
} 

Observe that the query contains three placeholders in the FILTER conditions.

obda-mixer instantiates the three placeholders with values retrieved from the columns field_production_totalt_NCS_month.[prfYear, month]; Observe that the second and the third placeholders will be instantiated to different values, although they have a common source part, since their id part differs. A possible instantiation of the query template above is:

PREFIX npdv: <http://sws.ifi.uio.no/vocab/npd-v2#>

SELECT *
WHERE {
  [ npdv:productionYear ?year ;
    npdv:productionMonth ?m ;
    npdv:producedGas     ?g ;
    npdv:producedOil     ?o 
 ]
 FILTER (?year > 2008) 
 FILTER(?m >= 1 && ?m <= 12 )
}